import React from "react";
import {Col, Row} from "reactstrap";
import Suggest from "../../../../../../components/YandexAPI/Suggest";
import Organization from "../../../../../../components/YandexAPI/Organization"

class DefaultItem extends React.Component {

    handleInput = e => {
        this.props.setEventEditData(this.props.constant, e.target.value);
    };

    render() {

        const data = this.props.data;
        const from = this.props.from;
        const itemId = this.props.id;
        const itemClass = this.props.class;
        const editStatus = this.props.editStatus;
        const typeData = this.props.typeData;

        return (
            <Row>
                <Col md={3} className={itemId !== 3 ? "align-self-center" : ''}>
                    <span className="event-content-list-name">{from}</span>
                </Col>
                <Col md={9}>
                    {!editStatus ? (
                        <div className={`event-content-list-item ${itemClass || ''}`}>
                            {data}
                        </div>
                    ) : (
                        typeData === 'city' ? (
                            <Suggest
                                id='cityEventEdit'
                                className={`${itemClass} event-content-list-item event-input-edit`}
                                value={this.props.data}
                                onChange={this.props.onChange}
                                placeholder='Город'
                            />
                            ) : typeData === 'organization' ? (
                                <Organization
                                    id='organizationEventEdit'
                                    className={`${itemClass} event-content-list-item event-input-edit`}
                                    value={this.props.data}
                                    onChange={this.props.onChange}
                                    placeholder='Город'
                                />
                            ) : (
                                <this.props.typeInput
                                    onChange={this.handleInput}
                                    defaultValue={this.props.data || ''}
                                    className={`event-content-list-item event-input-edit ${itemClass || ''}`}
                                />
                        )
                    )}
                </Col>
            </Row>
        )
    }
}

export default DefaultItem;